home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / vb3ex.zip / VB3EX.FRM (.txt) < prev    next >
Visual Basic Form  |  1992-03-01  |  7KB  |  167 lines

  1. VB3EX
  2. VISUAL BASICS #3 Example
  3. Form1,
  4.     LblWinDir
  5. Windows Directory:
  6. LblMessages
  7. TxtINIFile
  8. LblINIFile
  9.     INI File:
  10. TxtSection
  11. LblSection
  12. Section:
  13. TxtKey
  14. LblKey
  15. TxtValue
  16. LblValue
  17. Value:
  18. BtnWrite
  19. &Write
  20. BtnRead
  21. &Read
  22. BtnEdit
  23. &&Edit
  24. BtnQuit
  25. &Quit
  26. GetWindowsDirectory
  27. lpBufferc
  28. nSize6
  29. GetPrivateProfileString
  30. AppName
  31. KeyName
  32. Default
  33. ReturnedString
  34. MaxSize
  35. FileName&
  36. WritePrivateProfileString\
  37.     NewString
  38. StringFromINIn
  39. MaxStringLenO
  40. ReturnedStr
  41. Resultq
  42.     ResultStr
  43. WriteItemToINI|
  44. DataString
  45. INIFileName
  46. Form_Click#
  47. WinDir
  48. PathStringLength
  49. WindowsPathName
  50. Success
  51. WindowsDirectory!
  52. @    Form_Load]
  53. MB_ICONINFORMATION
  54. Label1
  55. Captiong
  56. Command3_ClickQ
  57. BtnQuit_Clicky
  58. BtnWrite_Clicky
  59. BtnSection
  60. BtnKey
  61. StringToINI
  62. Section
  63. SectnL
  64. TxtSection,
  65. TxtKey
  66. TxtValue4
  67. Value
  68. ShelRes>
  69. ShellStr
  70.     LblWindir
  71. LblINIFile
  72. INIFileNam
  73. Windows
  74. Keyy:
  75. ValyueP
  76. TxtINIFile
  77. FileNamE
  78. Command1_Click
  79. BtnRead_Click
  80. DeeFalt
  81. LblMessages
  82. Screen
  83. MousePointer
  84.     Launching
  85. NOTEPAD
  86. BtnEdit_Click2
  87. BtnEdit_GotFocus
  88. Form_GotFocus
  89. SectionName
  90. BtnRead
  91. Enabled
  92. TxtINIFile_Change
  93. TxtINIFile_KeyPress
  94. KeyAsciip
  95. Windows API calls!  Get 'em while they're hot!
  96. learn about your environment
  97. Kernelq
  98. read/write your application's 'private' INI file 
  99. Kernel#
  100. Kernel#
  101. Form_Load
  102. VB3EX.INI"
  103. Windows Directory: "
  104. BtnQuit_Click
  105. BtnWrite_Click
  106. Write FAILED."
  107. Write SUCCEEDED.
  108. StringToINI
  109. StringFromINI
  110. Function reads an item from an app's INI file.
  111.    -SectionName is the Application name
  112.    -KeyName is the Key to read from the ini file
  113.    -Default is the value to be supplied if the ini file doesn't exist or if the keym
  114.  hasn't been created/defined in the INI file.i
  115.    -ReturnedString is the string read from the INI file 
  116.    -ReturnedStringLen is the max allowable length of ReturnedStrings
  117.    -FileName is the INI file name.
  118. ALL OF THESE PARAMETERS MUST BE INITIALIZED for this API call to work.
  119.  TRIM OUT BLANKS
  120.  REMOVE CHR$(0) FROM END
  121. WinDir
  122. Author:
  123.  Barry Seymour, Vanguard Business Solutions
  124. Date:
  125.  29Aug91 
  126. Globals used:
  127.  None
  128. Functions Called:  GetWindowsDirectory, defined in GLOBAL.BAS as follows:i
  129. Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integere
  130. Explanation:   This Function returns a string containing the
  131.  name of the Windows directory.  The GetWindowsDirectory
  132.  function call is defined in GLOBAL.BAS (see above)c
  133.  and uses a Windows API call to the Kernel.e
  134.  IMPORTANT NOTE:   The string to contain the returned data MUST be fully
  135.  initialized prior to placing data in it, else an Unrecoverable 
  136.  Application Error (UAE) will result.  This Function initializes the
  137.  string with empty spaces so the result can be trimmed.i
  138.  EVEN SO, the result string has a null char at the end of it which
  139.  must be stripped away manually - RTrim$ or LTrim$ don't strip out
  140.  null chars.
  141.  ANOTHER IMPORTANT NOTE:  If your windows directory is in the ROOT, a
  142.  backslash is at the end of the string ("C:\").  If not, there is no
  143.  backslash at the end of the string ("C:\WINDOWS"). 
  144. Error trapping is also in this code, giving a STERN WARNING to the user.
  145. If this procedure fails, your system is mightily confused.
  146. linefeed for message formatting-
  147. The length is arbitrary, but MUST be defined.-
  148. Initialize the full string to SPACES.  The full length of the-
  149. string MUST be present before making the function call, else UAE!-
  150.  |--Trim trailing blanks   |-Trim null char at end of string.E
  151. C:\WINDOWS
  152. SYSTEM ERROR: Unable to determine Windows Directory.
  153. Error 
  154. Error Number Unknown."
  155. Assuming Windows Directory to be C:\WINDOWS.
  156. It is STRONGLY RECOMMENDED that you save your work "
  157. and SHUT DOWN this application."
  158. System Error
  159. BtnRead_Click
  160. Assign textbox contents to variables for API call.
  161. (API call won't take references to Textbox contents.)
  162. Section, Key or File name not found.
  163. Read SUCCEEDED."
  164. BtnEdit_Click
  165. Editing 
  166. NOTEPAD.EXE 
  167.